<script setup lang="ts">
  // import { Base64 } from 'js-base64';
definePageMeta({
  layout: 'default-custom',
  title: '客服',
  i18n: 'menu.custoService',
})
const userStore=useUserStore()
const iframeUrl = ref('')
// let chatUrl='http://game.wildwin.vip/chat/list?p='
let chatUrl='http://192.168.66.9:3000/chat/list?p='

onMounted(() => {
  // iframeUrl.value = './11.html'
  window.addEventListener('message', function(e){
     console.log('接受', e.data);
}, false);
  return
let reqMsg={
      uid: userStore.user.uid,
      game: 'G001',
      token: userStore.user.accessToken,
      avatar:  userStore.user.avatar,
      name:  userStore.user.username,
      type: 2,
      clientType: 'Browser'
}
let p = Base64.encode(JSON.stringify(reqMsg));

iframeUrl.value = chatUrl +  p
// console.log('地址', iframeUrl.value);
// console.log('reqMsg', reqMsg);
window.addEventListener('message', function(event) {
  // 如果你知道 iframe 的源，建议做安全校验
  if (event.origin !== 'http://localhost:3000') return;

  const message = event.data;

  if (message.type === 'buttonClicked') {
    console.log('接收到 iframe 消息:', message.data);

  }
});

})
</script>

<template>
  <div >
    <iframe :src="iframeUrl" frameborder="0" style="width: 100%; ; border: none"></iframe>
    <AppFooter />
  </div>
</template>
<style lang="css" scoped>

</style>
